package com.xixi.core.rpc.loadbalancer;

import com.xixi.core.rpc.spi.SpiLoader;

/**
 * @author: zxh
 * @date: 2024/8/27 14:52
 * @description: 负载均衡器工厂
 */
public class LoadBalancerFactory {

	static {
		SpiLoader.load(LoadBalancer.class);
	}

	// 默认负载均衡器
	private static final LoadBalancer DEFAULT_LOAD_BALANCER = new RoundRobinLoadBalancer();

	/**
	 * 获取实例
	 * @author zxh
	 * @param key 负载均衡器key
	 * @return 返回对应的负载均衡器实例
	 */
	public static LoadBalancer getInstance(String key) {
		return SpiLoader.getInstance(LoadBalancer.class, key);
	}
}
